﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EntityObjects;
using DAL_V1.App_Code.DBBroker;
namespace BAL.Controller
{
    public class ModifyReqControl
    {
        RequisitionDBBroker reqBroker;
        //DepartmentDBBroker deptBroker;
        List<Requisition> req_list;

        public ModifyReqControl()
        {
            reqBroker = RequisitionDBBroker.getRequisitionDBBroker();
            // deptBroker = DepartmentDBBroker.getDepartmentDBBroker();
        }

        public List<Requisition> getRequisitions(String status, String empId)
        {

            req_list = new List<Requisition>();
            req_list = reqBroker.getRequisitionByStatus(status, empId);
            return req_list;
        }

        public List<RequisitionItems> getRequisitionItems(int reqFormId)
        {
            List<RequisitionItems> list = reqBroker.getRequisitionItemsbyReqFormId(reqFormId);
            return list;
        }


        public void updateReqDetails(int reqQty, int formId, String itemId)
        {
            RequisitionDetails r = new RequisitionDetails();
            r.RequestedQty = reqQty;

            reqBroker.updateRequisitionDetails(r, formId, itemId);
        }

        public Requisition getRequisitionId(String empId)
        {
            return reqBroker.getRequsitionByEmpIdAndAppliedStatus(empId);
        }




        public void deleteReqDetails(int formId, String itemId)
        {
            reqBroker.deleteRequisitionDetails(formId, itemId);

        }

        //public int insertRequisition(Requisition r)
        //{
        //    //first call dbbroker method to save requisition

        //    //reqBroker.addRequisition(r);
        //    //List<RequisitionDetails> reqDetails = r.ReqDetails_list;
        //    //foreach (RequisitionDetails rq in reqDetails)
        //    //{
        //    //    reqBroker.addRequisitionDetails(rq);
        //    //}


        //    //return reqBroker.addRequisition(r);
        //}
    }

}
